package com.wcity.manage.service.impl;

import com.wcity.manage.dao.dal.model.PageModel;
import com.wcity.manage.dao.mapper.AnnouncementMapper;
import com.wcity.manage.dao.mapper.PropertyFixMapper;
import com.wcity.manage.dao.mapper.UserMapper;
import com.wcity.manage.dao.model.Announcement;
import com.wcity.manage.dao.model.Block;
import com.wcity.manage.dao.model.SeedAnn;
import com.wcity.manage.dao.model.User;
import com.wcity.manage.service.announcement.AnnouncementService;
import org.springframework.stereotype.Service;

import javax.annotation.Resource;
import java.util.List;

/**
 * 公告管理
 * Created by zm on 2016/12/15.
 */
@Service
public class AnnouncementServiceImpl implements AnnouncementService {

    @Resource private AnnouncementMapper announcementMapper;
    @Resource private PropertyFixMapper propertyFixMapper;
    @Resource private UserMapper userMapper;

    /**
     * 分页查询公告列表
     * @param pageModel
     * @return
     */
    @Override
    public List<Announcement> getPayAnnListPage(PageModel pageModel) {
        return announcementMapper.findListPage( pageModel );
    }

    /**
     * 获取小区名称
     * @param id
     * @return
     */
    @Override
    public List<Block> getBlockName(int id) {
        return announcementMapper.getBlockName( id );
    }

    /**
     * 添加公告
     * @param ann
     * @return
     */
    @Override
    public int annAdd(Announcement ann) {
        return announcementMapper.insert(ann);
    }

    /**
     * 跳转到修改页面
     * @param id
     * @return
     */
    @Override
    public Announcement getAnnInfo(String id) {
        return announcementMapper.getAnnInfo ( id );
    }

    /**
     * 修改
     * @param ann
     * @return
     */
    @Override
    public int annEdit(Announcement ann) {
        return announcementMapper.update( ann );
    }

    /**
     * 删除
     * @param id
     * @return
     */
    @Override
    public int annDelect(String id) {
        return announcementMapper.delete( id );
    }

    /**
     * 发送公告
     * @param seedAnn
     * @return
     */
    @Override
    public int sendAnn(SeedAnn seedAnn) {
        return announcementMapper.sendAdd ( seedAnn );
    }

    /**
     * 获取社区公告列表
     * @param pageModel
     * @return
     */
    @Override
    public List<Announcement> getProAnnList(PageModel pageModel) {
        return announcementMapper.IFindListPage( pageModel );
    }

    /**
     * 获取小区信息
     * @param blockId
     * @return
     */
    @Override
    public Block getUserId(String blockId) {
        return propertyFixMapper.getUserId( blockId );
    }

    /**
     * 获取物业管理员信息
     * @param userId
     * @return
     */
    @Override
    public User getUserInfo(int userId) {
        return userMapper.find( userId );
    }

    @Override
    public Announcement getAnnInfo1(String annId, String blockId) {
        return announcementMapper.getAnnInfo1(annId , blockId);
    }

}
